<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<html>
<head>
    <meta charset="utf-8">
    <title>质量奖惩管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdQualityRewardsMessageTable" lay-filter="wQbdQualityRewardsMessageTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdQualityRewardsMessageHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="zljcxxgl_xzan2" event="add" css="layui-btn layui-btn-sm fillBtn" >
                <span>新增</span>
            </@f.a>
            <@f.a alias="zljcxxgl_scan2" event="delete" css="layui-btn layui-btn-sm" >
                <span>删除</span>
            </@f.a>
            <@f.a alias="zljcxxgl_dcan1,zljcxxgl_dcan2" event="export" css="layui-btn layui-btn-sm" >
                <span>导出</span>
            </@f.a>
            <!--<a class="layui-btn layui-btn-sm" lay-event="export">
                <i class="layui-icon layui-icon-export"></i>
                <span>导出</span>
            </a>-->
            <@f.a alias="zljcxxgl_dran2" event="import" css="layui-btn layui-btn-sm" >
                <span>导入</span>
            </@f.a>
            <!--<a class="layui-btn layui-btn-sm" lay-event="import">
                <span>导入</span>
            </a>-->
        </div>
        <form class="layui-form" action="" lay-filter="wQbdQualityRewardsMessageQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    
                         <div class="qbdms-listForm">
                                <label class="layui-form-label">事件名称</label>
                             <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value" name="Q_incidentName_SL" placeholder="请输入"/>
                             </div>
                         </div>
                    
                         <div class="qbdms-listForm">
                                <label class="layui-form-label">类别</label>
                             <div class="layui-input-block">
                                <select name="Q_qualityType_S" class="layui-input filter-value" lay-search="">
                                    <option></option>
                                </select>
                             </div>
                                <!--<input type="text" class="layui-input filter-value" name="Q_qualityType_SL" placeholder="请输入"/>-->
                        </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <!--<button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">-->
                            <!--<i class="iconfont data-iconcommon_downarrow screen"></i>-->
                        <!--</button>-->
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdQualityRewardsMessageRightToolsBar">
    {{# if(d.dataFrom =='其他' && '${currentUserId}'==d.createBy){}}
    <@f.a alias="zljcxxgl_bjan2" event="edit" css="RightBtn" >编辑</@f.a>
    <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
    {{#  } }}
    <@f.a alias="zljcxxgl_mxan1,zljcxxgl_mxan2" event="particulars" css="RightBtn" >明细</@f.a>
    {{# if(d.dataFrom =='其他' && '${currentUserId}'==d.createBy){}}
    <@f.a alias="zljcxxgl_scan2" event="del" css="RightBtn" >删除</@f.a>
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'form', 'common','publicMethods','jquery','layer'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        common.tableSort('wQbdQualityRewardsMessageTable');

        var tableH=publicMethods.tabHeight();

        //第一个实例
        table.render({
            elem: '#wQbdQualityRewardsMessageTable'
            ,height:tableH
            ,url: '${ctx}/qbdms/wQbdQualityRewardsMessage/list'
            ,page: publicMethods.pageFun()
            ,defaultToolbar: ['']
            ,limit: 20
            ,toolbar: '#wQbdQualityRewardsMessageHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                    ,{field: 'id', title: '主键id',hide:true,sort:false, sortname: 'id',minWidth:'100'}
                    ,{field: 'incidentName', title: '事件名称', sort:false, sortname: 'incident_name',minWidth:'100'}
                    ,{field: 'companyName', title: '单位名称', sort:false, sortname: 'company_name',minWidth:'100'}
                    ,{field: 'qualityType', title: '类别', sort:false, sortname: 'quality_type',minWidth:'80'}
                    ,{field: 'aggregateAmount', title: '奖励/处罚总金额', sort:false, sortname: 'aggregate_amount',minWidth:'150',align:'right',templet: function (d) {
                        if (d.aggregateAmount != null){
                            return '<span style="color: #F07878">'+d.aggregateAmount+'</span>';
                        }else {
                            return '<span style="color: #F07878">'+0+'</span>';
                        }
                    }}
                    ,{field: 'rewardsReason', title: '奖励/处罚原因', sort:false, sortname: 'rewards_reason',minWidth:'180'}
                    ,{field: 'dataFrom', title: '来源', sort:false, sortname: 'data_from',minWidth:'80'}
                    ,{field: 'fillmanaccount', title: '填写人账号',hide:true, sort:false, sortname: 'fillmanaccount',minWidth:'100'}
                    ,{field: 'filldept', title: '填写部门',hide:true, sort:false, sortname: 'filldept',minWidth:'100'}
                    ,{field: 'filldeptid', title: '填写部门编码',hide:true, sort:false, sortname: 'filldeptid',minWidth:'120'}
                    ,{field: 'belongdeptname', title: '所属单位(用于数据纵向筛选)',hide:true, sort:false, sortname: 'belongdeptname',minWidth:'380'}
                    ,{field: 'reportStatus', title: '上报状态',hide:true, sort:false, sortname: 'report_status',minWidth:'100'}
                    ,{field: 'returnmsg', title: '错误信息',hide:true, sort:false, sortname: 'returnmsg',minWidth:'100'}
                    ,{field: 'filldepthospital', title: '填写部门院',hide:true, sort:false, sortname: 'filldepthospital',minWidth:'100'}
                    ,{field: 'filldepthospitalid', title: '填写部门院编码',hide:true, sort:false, sortname: 'filldepthospitalid',minWidth:'180'}
                    //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.reportDate,"1");
                    //如需转换为HH:mm:ss: return publicMethods.timeData(d.reportDate,"2");
                    // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.reportDate);
                    ,{field: 'reportDate', title: '上报日期',hide:true, sort:false, sortname: 'report_date',minWidth:'100',templet: function (d) {
                    return publicMethods.timeData(d.reportDate);
                }}
                    ,{field: 'reportReason', title: '中间件操作失败原因',hide:true, sort:false,minWidth:'200' ,sortname: 'report_reason'}
                ,{
                    fixed: 'right',
                    title: '管理',
                    minWidth:'120',
                    toolbar: '#wQbdQualityRewardsMessageRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['incidentName','companyName','qualityType','aggregateAmount','rewardsReason','dataFrom','fillmanaccount','filldept','filldeptid',
                'belongdeptname','reportStatus','returnmsg','filldepthospital','filldepthospitalid','reportDate','reportReason']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });

        var lbList = eval('${lbList}'); //型号代号
        common.initDicData("Q_qualityType_S", lbList);

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdQualityRewardsMessageTable',true);

        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            publicMethods.reflashDate({startName:'.start_time0',endName:'.end_time0'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdQualityRewardsMessageTable","wQbdQualityRewardsMessageQueryForm",{where:{}},isClear);
            common.initDicData("Q_qualityType_S", lbList);
        }

        table.on('toolbar(wQbdQualityRewardsMessageTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/wQbdQualityRewardsMessage/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                function open(url , param){
                    var curUrl = url;
                    layer.open({
                        type: 2,
                        area: ['700px', '520px'],
                        title: ['自定义导出', 'font-size:14px;'],
                        content: '${ctx}/qbdms/wQbdQualityRewardsMessage/view/export',
                        btnAlign: 'c',
                        skin: 'qbdms-layerFormBtn',
                        btn: ['确定', '取消'],
                        yes: function(index, layero){
                            url = curUrl;
                            var iframeWin = window["layui-layer-iframe" + index];
                            var data = iframeWin.getData();
                            if(data){
                                url = url + "?data=" + JSON.stringify(data) + param;
                                window.location.href = encodeURI(url)
                            }
                        }
                    });
                }
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = '${ctx}/qbdms/wQbdQualityRewardsMessage/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdQualityRewardsMessageQueryForm']").find(".filter-value").each(function (i, value) {
                                param += "&" + this.name + "=" + this.value
                            });
                            open(url, param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = '${ctx}/qbdms/wQbdQualityRewardsMessage/exportData';
                            open(url, "&id=" + ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdQualityRewardsMessageTable',"/qbdms/wQbdQualityRewardsMessage/importData",true,"/importTemplates/质量奖惩信息.xlsx");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdQualityRewardsMessageTable');
                    dateReflash();
                    form.render();
                    break;
            };
        });

        table.on('tool(wQbdQualityRewardsMessageTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":

                    window.location.href = '${ctx}/qbdms/wQbdQualityRewardsMessage/view/add?id='+data.id;
                    break;
                case "particulars":

                    window.location.href = '${ctx}/qbdms/wQbdQualityRewardsMessage/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "${ctx}/qbdms/wQbdQualityRewardsMessage/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdQualityRewardsMessageTable");
    });
</script>
</body>
</html>